import req from '../utils/request';
import * as URL from '../constans/api';
// 获取三级页面商品列表
export function getSubCategoryGoods(data) {
  return req({
    url: URL.SUB_CATEGORY_GOODS,
    method: 'post',
    data,
  })
    .then((res) => {
      return res.data;
    })
    .catch((err) => Promise.reject(err.response.data));
}
// 获取详情页
export function getGoods(params) {
  return req({
    url: URL.GOODS,
    method: 'get',
    params,
  })
    .then((res) => {
      return res.data;
    })
    .catch((err) => Promise.reject(err.response.data));
}
// 获取配送地址
export function getArea() {
  return req({
    url: 'https://yjy-oss-files.oss-cn-zhangjiakou.aliyuncs.com/tuxian/area.json',
    method: 'get',
  })
    .then((res) => {
      return res.data;
    })
    .catch((err) => Promise.reject(err.response.data));
}
// 获取详情页
export function getGoodsRelevant(params) {
  return req({
    url: URL.GOODS_RELEVANT,
    method: 'get',
    params,
  })
    .then((res) => {
      return res.data;
    })
    .catch((err) => Promise.reject(err.response.data));
}
// 获取热销推荐
export function getGoodsHot(params) {
  return req({
    url: URL.GOODS_HOT,
    method: 'get',
    params,
  })
    .then((res) => {
      return res.data;
    })
    .catch((err) => Promise.reject(err.response.data));
}
